package com.fyzk.activity.dialog;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tyjc.lottery.R;

/**
 * 对话框形式的Activity
 * @author fxs
 *
 */
public abstract class BetCheckBaseDialog extends Activity implements View.OnClickListener{
	
	private TextView away_tv;
	private TextView home_tv;
	
	protected LinearLayout center_ll;
	
	private TextView bottom_sure_tv;
	private TextView bottom_cancel_tv;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.betcheckdialog);
		//设置不可点击边框以外区域
		if(Build.VERSION.SDK_INT >= 11 ){
			setFinishOnTouchOutside(false);
		}else{
			
		}
		
		initView();
	}
	
	/**
	 * 控件初始化
	 */
	private void initView(){
		away_tv = (TextView) findViewById(R.id.betcheckdialog_away_tv);
		away_tv.setText(setAway());
		home_tv = (TextView) findViewById(R.id.betcheckdialog_home_tv);
		home_tv.setText(setHome());
		center_ll = (LinearLayout) findViewById(R.id.betcheckdialog_center_ll);
		View view = addCenterView();
		if (view != null) {
			center_ll.addView(view);
		}
		
		bottom_cancel_tv = (TextView) findViewById(R.id.betcheckdialog_cancel);
		bottom_cancel_tv.setOnClickListener(this);
		bottom_sure_tv = (TextView) findViewById(R.id.betcheckdialog_sure);
		bottom_sure_tv.setOnClickListener(this);
		
	}
	/**
	 * 设置客队
	 * @return
	 */
	protected abstract String setAway();
	/**
	 * 设置主队
	 * @return
	 */
	protected abstract String setHome();
	/**
	 * 添加中间view控件
	 * @return
	 */
	protected abstract View addCenterView();
	/**
	 * 点击确定按钮
	 */
	protected abstract void onClickSure();
	/**
	 * 点击取消按钮
	 */
	protected abstract void onClickCancel();
	
	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.betcheckdialog_cancel:
			onClickCancel();
			break;
		case R.id.betcheckdialog_sure:
			onClickSure();
			break;
		default:
			break;
		}
		
		
	}
}
